package com.qn.strategy.factory;

import com.qn.strategy.ICouponDiscount;
import org.springframework.util.Assert;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class PromotionTypeServiceStrategyFactory {
    private static Map<String, ICouponDiscount> services = new ConcurrentHashMap<>();

    public static ICouponDiscount getByUserType(String type){
        return services.get(type);
    }

    public static void register(String userType,ICouponDiscount iCouponDiscount){
        Assert.notNull(userType,"userType 不能为null");
        services.put(userType, iCouponDiscount);
    }
}
